YAHOO.namespace("pingmob");
YAHOO.namespace("pingmob.container");

YAHOO.util.Event.onDOMReady(function () {
    YAHOO.pingmob.cardList = function () {

        var runJob = function (p_oEvent) {
            YAHOO.util.Connect.asyncRequest(
                'POST',
                '/batch/jobs/' + p_oEvent.target.title,
                {
                    success: function (o) {
                        if (o.responseText != "") {
                            alert("任务被执行,请从任务管理中查看执行状态.");
                        }
                    },
                    failure: function (o) {
                        alert(o.statusText);
                    },
                    scope: this
                },
                "jobParameters="+ encodeURIComponent("{startDate="+new Date().getTime()+"}")+"&origin=job"
            );
        };

        //button.
        var m18n7EarlyStageJob_btn = new YAHOO.widget.Button("m18n7EarlyStageJob", {label: "M18,N7注册前180天赠卡", onclick: { fn: runJob } });
        var m18n7LaterStageJob_btn = new YAHOO.widget.Button("m18n7LaterStageJob", {label: "M18,N7注册后180-720天赠卡", onclick: { fn: runJob } });
        var n707EarlyStageJob_btn = new YAHOO.widget.Button("n707EarlyStageJob", {label: "N707注册前60天赠卡", onclick: { fn: runJob } });
        var n707LaterStageJob_btn = new YAHOO.widget.Button("n707LaterStageJob", {label: "N707注册后60-720天赠卡", onclick: { fn: runJob } });
        var questionJob_btn = new YAHOO.widget.Button("questionJob", {label: "离线答疑超时未解答状态更新", onclick: { fn: runJob } });
        var free_questionJob_btn = new YAHOO.widget.Button("freeQuestionJob", {label: "免费离线答疑超时未解答状态更新", onclick: { fn: runJob } });
        var all20000PointsJob_btn = new YAHOO.widget.Button("all20000PointsJob", {label: "所有用户赠送20000星币", onclick: { fn: runJob } });


        return {
            btn1: m18n7EarlyStageJob_btn,
            btn2: m18n7LaterStageJob_btn,
            btn3: n707EarlyStageJob_btn,
            btn4: n707LaterStageJob_btn
        };

    }();
});
